<template>
	<view class="container">
		<view class="header">
			<text class="title">狼人杀</text>
			<text class="subtitle">{{ currentPhase }}</text>
		</view>

		<view class="game-area">
			<view class="players-container">
				<view class="players-column">
					<view v-for="(player, index) in leftPlayers" :key="index" class="player-card"
						:class="{ 'player-dead': !player.alive }">
						<view class="player-avatar-container">
							<image :src="player.avatar" class="player-avatar" mode="aspectFill"></image>
							<view class="player-status"
								:class="{ 'status-alive': player.alive, 'status-dead': !player.alive }"></view>
						</view>
						<text class="player-name">{{ player.name }}</text>
						<text class="player-role">{{ player.role }}</text>
					</view>
				</view>
				<view class="players-column">
					<view v-for="(player, index) in rightPlayers" :key="index" class="player-card"
						:class="{ 'player-dead': !player.alive }">
						<view class="player-avatar-container">
							<image :src="player.avatar" class="player-avatar" mode="aspectFill"></image>
							<view class="player-status"
								:class="{ 'status-alive': player.alive, 'status-dead': !player.alive }"></view>
						</view>
						<text class="player-name">{{ player.name }}</text>
						<text class="player-role">{{ player.role }}</text>
					</view>
				</view>
			</view>

			<view class="game-controls">
				<button @click="startGame" class="btn btn-start">
					<text class="btn-text">开始游戏</text>
				</button>
				<button @click="nextPhase" class="btn btn-next">
					<text class="btn-text">下一阶段</text>
				</button>
			</view>

			<view class="game-info">
				<text class="players-text">剩余玩家: {{ alivePlayers }}</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				players: [{
						name: '玩家1',
						role: '村民',
						alive: true,
						avatar: '/static/user/1.jpg'
					},
					{
						name: '玩家2',
						role: '狼人',
						alive: true,
						avatar: '/static/user/2.jpg'
					},
					{
						name: '玩家3',
						role: '预言家',
						alive: true,
						avatar: '/static/user/3.jpg'
					},
					{
						name: '玩家4',
						role: '村民',
						alive: true,
						avatar: '/static/user/4.jpg'
					},
					{
						name: '玩家5',
						role: '村民',
						alive: true,
						avatar: '/static/user/1.jpg'
					},
					{
						name: '玩家6',
						role: '狼人',
						alive: true,
						avatar: '/static/user/2.jpg'
					},
					{
						name: '玩家7',
						role: '女巫',
						alive: true,
						avatar: '/static/user/3.jpg'
					},
					{
						name: '玩家8',
						role: '猎人',
						alive: true,
						avatar: '/static/user/4.jpg'
					},
				],
				currentPhase: '准备阶段',
				gamePhases: ['夜晚', '白天', '投票'],
				currentPhaseIndex: 0,
			}
		},
		computed: {
			alivePlayers() {
				return this.players.filter(player => player.alive).length;
			},
			leftPlayers() {
				return this.players.slice(0, Math.ceil(this.players.length / 2));
			},
			rightPlayers() {
				return this.players.slice(Math.ceil(this.players.length / 2));
			}
		},
		methods: {
			startGame() {

				this.currentPhase = this.gamePhases[0];
				this.currentPhaseIndex = 0;

			},
			nextPhase() {

				this.currentPhaseIndex = (this.currentPhaseIndex + 1) % this.gamePhases.length;
				this.currentPhase = this.gamePhases[this.currentPhaseIndex];

			},

		}
	}
</script>

<style>
	.container {
		padding: 15px;
		background-color: #f5f7fa;
		min-height: 100vh;
		font-family: Arial, sans-serif;
	}

	.header {
		text-align: center;
		margin-bottom: 30px;
	}

	.title {
		font-size: 36px;
		font-weight: bold;
		color: #2c3e50;
		text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
		margin-bottom: 8px;
	}

	.subtitle {
		font-size: 20px;
		color: #34495e;
		font-weight: 300;
	}

	.game-area {
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.players-container {
		display: flex;
		justify-content: space-between;
		width: 100%;
		max-width: 1000px;
		margin-bottom: 30px;
	}

	.players-column {
		display: flex;
		flex-direction: column;
		align-items: center;
		width: 48%;
	}

	.player-card {
		background-color: #ffffff;
		border-radius: 12px;
		box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
		padding: 12px;
		margin: 10px 0;
		width: 100%;
		max-width: 180px;
		text-align: center;
		transition: all 0.3s ease;
		position: relative;
		overflow: hidden;
	}

	.player-card::before {
		content: '';
		position: absolute;
		top: -50%;
		left: -50%;
		width: 200%;
		height: 200%;
		background: linear-gradient(to bottom right,
				rgba(255, 255, 255, 0.2) 0%,
				rgba(255, 255, 255, 0.05) 40%,
				rgba(255, 255, 255, 0) 50%);
		transform: rotate(-45deg);
		transition: all 0.3s ease;
	}

	.player-card:hover::before {
		top: -30%;
		left: -30%;
	}

	.player-card:hover {
		transform: translateY(-3px) scale(1.02);
		box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
	}

	.player-dead {
		opacity: 0.7;
		filter: grayscale(70%);
	}

	.player-avatar-container {
		position: relative;
		width: 70px;
		height: 70px;
		margin: 0 auto 10px;
	}

	.player-avatar {
		width: 100%;
		height: 100%;
		border-radius: 50%;
		border: 3px solid #3498db;
		transition: all 0.3s ease;
	}

	.player-status {
		position: absolute;
		bottom: 3px;
		right: 3px;
		width: 12px;
		height: 12px;
		border-radius: 50%;
		border: 2px solid #ffffff;
	}

	.status-alive {
		background-color: #2ecc71;
	}

	.status-dead {
		background-color: #e74c3c;
	}

	.player-name {
		font-size: 16px;
		font-weight: bold;
		color: #2c3e50;
		margin-bottom: 4px;
	}

	.player-role {
		font-size: 12px;
		color: #7f8c8d;
		font-style: italic;
	}

	.game-controls {
		margin-top: 25px;
		display: flex;
		justify-content: center;
	}

	.btn {
		padding: 12px 24px;
		font-size: 16px;
		border-radius: 25px;
		margin: 0 12px;
		cursor: pointer;
		transition: all 0.3s ease;
		border: none;
		outline: none;
		position: relative;
		overflow: hidden;
	}

	.btn::after {
		content: '';
		position: absolute;
		top: 50%;
		left: 50%;
		width: 5px;
		height: 5px;
		background: rgba(255, 255, 255, 0.5);
		opacity: 0;
		border-radius: 100%;
		transform: scale(1, 1) translate(-50%);
		transform-origin: 50% 50%;
	}

	.btn:active::after {
		animation: ripple 1s ease-out;
	}

	@keyframes ripple {
		0% {
			transform: scale(0, 0);
			opacity: 1;
		}

		20% {
			transform: scale(25, 25);
			opacity: 1;
		}

		100% {
			opacity: 0;
			transform: scale(40, 40);
		}
	}

	.btn-text {
		position: relative;
		z-index: 1;
	}

	.btn-start {
		background-color: #2ecc71;
		color: white;
		box-shadow: 0 4px 6px rgba(46, 204, 113, 0.3);
	}

	.btn-next {
		background-color: #3498db;
		color: white;
		box-shadow: 0 4px 6px rgba(52, 152, 219, 0.3);
	}

	.btn:hover {
		transform: translateY(-2px) scale(1.05);
		box-shadow: 0 7px 14px rgba(0, 0, 0, 0.2);
	}

	.game-info {
		margin-top: 30px;
		text-align: center;
	}

	.players-text {
		font-size: 18px;
		color: #34495e;
		font-weight: 500;
	}
</style>